<template>
  <div>
    <Head/>
    <left/>
    <div style="position: absolute;top: 60px;left: 200px">
      <table>
        <tr>
          <td>id</td>
          <td>名称</td>
          <td>操作</td>
        </tr>
        <tr v-for="i in yewu" :key="i.id">
          <td>{{ i.id }}</td>
          <td>{{ i.name }}</td>
          <td>
            <router-link :to="{path:'/add_shenq',query:{'id':i.id}}">申请</router-link>

          </td>
        </tr>
      </table>

    </div>
  </div>
</template>

<script>
import maxios from "@/http/axios";
import head from "@/components/head";
import left from "@/components/left";

export default {
  components: {
    'Head': head,
    'left': left
  },
  name: "add_work",
  data() {
    return {
      form: {},//
      list: [[{"label": "名称", "key": "name"}, {"label": "类型", "key": "type"}, {"label": "值", "key": "value"}]],
      value: {},
      number: 1,
      name: '',
      yewu: [],


    }
  },
  methods: {
    add() {
      this.list.push([{"label": "名称", "key": "name"}, {"label": "类型", "key": "type"}, {"label": "值", "key": "value"}])
      this.number += 1
    },
    save() {
      var l = []
      for (var i = 0; i < this.number; i++) {
        var name = i + "name" + i
        var type = i + "type" + i
        var v = i + "value" + i
        var dict = {"name": this.value[name], "value": this.value[v], "type": this.value[type]}
        l.push(dict)
      }
      console.log(l)
      maxios('/work/work', 'post', {"name": this.name, "params": JSON.stringify(l)})
          .then(res => {
            if (res.code == 200) {
              alert('添加成功')
            } else {
              alert('添加失败')
            }
          })
    },
    getyewu() {
      maxios('/work/work', 'get').then(res => {
        if (res.code == 200) {
          this.yewu = res.list
        }
      })
    }
  },
  mounted() {
    this.getyewu()
  }
}
</script>

<style scoped>

</style>